package org.jivesoftware.smackx.workgroup.ext.notes;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

public class ChatNotes extends IQ
{
  public static final String ELEMENT_NAME = "chat-notes";
  public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
  private String notes;
  private String sessionID;

  public static final String replace(String paramString1, String paramString2, String paramString3)
  {
    String str;
    if (paramString1 == null)
      str = null;
    while (true)
    {
      while (true)
      {
        return str;
        if (paramString3 != null)
          break;
        str = paramString1;
      }
      int i = paramString1.indexOf(paramString2, 0);
      if (i >= 0)
      {
        char[] arrayOfChar1 = paramString1.toCharArray();
        char[] arrayOfChar2 = paramString3.toCharArray();
        int j = paramString2.length();
        StringBuilder localStringBuilder = new StringBuilder(arrayOfChar1.length);
        localStringBuilder.append(arrayOfChar1, 0, i).append(arrayOfChar2);
        int k = i + j;
        int l = k;
        while (true)
        {
          int i1;
          while (true)
          {
            i1 = paramString1.indexOf(paramString2, k);
            if (i1 > 0)
              break;
            localStringBuilder.append(arrayOfChar1, l, arrayOfChar1.length - l);
            str = localStringBuilder.toString();
          }
          localStringBuilder.append(arrayOfChar1, l, i1 - l).append(arrayOfChar2);
          k = i1 + j;
          l = k;
        }
      }
      str = paramString1;
    }
  }

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<").append("chat-notes").append(" xmlns=\"").append("http://jivesoftware.com/protocol/workgroup").append("\">");
    localStringBuilder.append("<sessionID>").append(getSessionID()).append("</sessionID>");
    if (getNotes() != null)
      localStringBuilder.append("<notes>").append(getNotes()).append("</notes>");
    localStringBuilder.append("</").append("chat-notes").append("> ");
    return localStringBuilder.toString();
  }

  public String getNotes()
  {
    return this.notes;
  }

  public String getSessionID()
  {
    return this.sessionID;
  }

  public void setNotes(String paramString)
  {
    this.notes = paramString;
  }

  public void setSessionID(String paramString)
  {
    this.sessionID = paramString;
  }

  public static class Provider
  implements IQProvider
  {
    public IQ parseIQ(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      ChatNotes localChatNotes = new ChatNotes();
      int i = 0;
      while (true)
      {
        int j;
        label91: 
        do
          while (true)
          {
            do
              while (true)
              {
                if (i != 0)
                  return localChatNotes;
                j = paramXmlPullParser.next();
                if (j != 2)
                  break label91;
                if (!(paramXmlPullParser.getName().equals("sessionID")))
                  break;
                localChatNotes.setSessionID(paramXmlPullParser.nextText());
              }
            while (!(paramXmlPullParser.getName().equals("text")));
            localChatNotes.setNotes(paramXmlPullParser.nextText().replaceAll("\\\\n", "\n"));
          }
        while ((j != 3) || (!(paramXmlPullParser.getName().equals("chat-notes"))));
        i = 1;
      }
    }
  }
}